package com.shanzmoo.merchant.server.api.web.merchant;

import com.shanzmoo.base.bean.SHttpResponse;
import com.shanzmoo.base.constant.e.LoginUserType;
import com.shanzmoo.db.module.merchant.domain.dto.MerchantOrderSaveDto;
import com.shanzmoo.db.module.merchant.domain.vo.MerchantOrderVo;
import com.shanzmoo.merchant.server.api.aspect.UserAuth;
import com.shanzmoo.merchant.server.api.manager.merchant.MerchantOrderManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 支付订单管理控制器
 * @author fs
 */
@Slf4j
@Api(tags = "订单管理")
@RestController
@RequestMapping("/merchant-order")
@RequiredArgsConstructor
public class MerchantOrderController {
    private final MerchantOrderManager merchantOrderManager;
    @ApiOperation(value = "扫码下单")
    @PostMapping("/create")
    @UserAuth({LoginUserType.SH_TEMP,LoginUserType.SH_HUIYUAN})
    public SHttpResponse<MerchantOrderVo> create(@Valid @RequestBody MerchantOrderSaveDto saveDto) {
        MerchantOrderVo order = merchantOrderManager.createOrder(saveDto);
        return SHttpResponse.ok(order);
    }
}
